<me:SDBASE x:Class="WPFExcelReport.TYCTYP"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"  
                    xmlns:me="clr-namespace:WPFExcelReport" 
                     xmlns:WF="clr-namespace:WPFExcelReport;assembly=TICC_WFEVENTS"  
                     xmlns:Localization="clr-namespace:Localization;assembly=Localization"  
                     x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:SDBASE.Resources>
        <CollectionViewSource   x:Key="vwMaster" />
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTConverter  x:Key="not"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:SDBASE.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" HorizontalAlignment="Left" >
            <WrapPanel >
                 <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="{Binding Source={Localization:Translate Word=关键字:}}"/>
                    <ex:TXT72 MaxLength="3" Grid.Column="1" Text="{Binding SDSA,ElementName=TV}" Width="200" />
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                        </Button.Background>
                    </Button>
                    <TextBlock Grid.Column="1" >查询</TextBlock>
                </Grid>
                
                    <Grid Margin="10,0,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" >新类型</TextBlock>
                        <ex:TXT72 MaxLength="15" CharacterCasing="Upper" Grid.Column="1"  
                                  Text="{Binding KEY,ElementName=TV}" Width="80" FontSize="18" />
                    </Grid>
             
            </WrapPanel>
           
        </StackPanel>
        <Border Grid.Row="1" BorderThickness="2,2,0,0" >
            <Grid >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="1*"></RowDefinition>
                </Grid.RowDefinitions>
                <StackPanel >
                    <WrapPanel  >
                        <Grid Margin="10,0,0,0"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button   Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                        <Grid Margin="10,0,0,0"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button   Click="EditCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                        <Grid Margin="10,0,0,0"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                        <Grid Margin="10,0,0,0"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button    Click="CopyCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/copy.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                       
                        <Grid Margin="10,0,0,0" Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                        <WrapPanel >
                            <Grid Margin="10,0,0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" >类型</TextBlock>
                                <ex:TXT72 CharacterCasing="Upper" Grid.Column="1" IsReadOnly="{Binding IsKEY,ElementName=TV,Converter={StaticResource not}}"  
                                          Text="{Binding KEY,Source={StaticResource ResourceKey=vwMaster},Converter={StaticResource gb2312}}"  Width="80" />
                            </Grid>
                        </WrapPanel>
                    </WrapPanel>
                    <StackPanel  IsEnabled="{Binding IsEdit,ElementName=TV}"> 
                        <Grid Margin="20,20,20,20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" >计算公式g/km:</TextBlock>
                            <ex:TXT72 CharacterCasing="Upper" Grid.Column="1" 
                                      IsReadOnly="{Binding IsEdit,ElementName=TV,Converter={StaticResource not}}" 
                                         Text="{Binding DES,Source={StaticResource ResourceKey=vwMaster},Converter={StaticResource gb2312}}" Width="400"/>
                        </Grid>
                        <Grid Margin="20,20,20,20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" >简述:</TextBlock>
                            <ex:TXT72 CharacterCasing="Upper" Grid.Column="1" IsReadOnly="{Binding IsEdit,ElementName=TV,Converter={StaticResource not}}"  
                                         Text="{Binding SDES,Source={StaticResource ResourceKey=vwMaster},Converter={StaticResource gb2312}}"  Width="200" />
                        </Grid> 
                    </StackPanel>
                </StackPanel>
                <DataGrid  Grid.Row="1"  
                   VerticalAlignment="Top" 
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"  
                   IsReadOnly="True"
                   Name="dlgMaster"
                   ItemsSource="{Binding Source={StaticResource vwMaster}}" 
                   IsSynchronizedWithCurrentItem="True"
                   RowDetailsVisibilityMode="Visible"  
                    >
                    <DataGrid.Columns>
                        <DataGridTextColumn Binding="{Binding Path=KEY}" Header="{Binding Source={Localization:Translate Word=键}}"  Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=DES,Converter={StaticResource gb2312}}" Header="{Binding Source={Localization:Translate Word=计算公式g/km}}"  Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=SDES,Converter={StaticResource gb2312}}" Header="{Binding Source={Localization:Translate Word=简述}}"  Width="Auto" />
                    </DataGrid.Columns>
                </DataGrid>                
            </Grid>
        </Border>
    </Grid>
</me:SDBASE>
